
const app = getApp()
import api from '../../http/api'
import storage from '../../utils/storage'
Page({


  data: {
    commentValue: "",
    videoInfo: [],
    commentSet: [],
    host: app.globalData.HOST_ADDRESS,
    clientConfig:storage.getGlobalData()
  },

  commentInputEvent(e) {
    this.setData({
      commentValue: e.detail.value
    })
  },
  onLoad: function (options) {
    console.log(app.globalData.currentVideoInfo)
    this.setData({
      videoInfo: app.globalData.currentVideoInfo
    })
    wx.setNavigationBarTitle({
      title: this.data.videoInfo.coursePO.courseTitle,
    })
    this.listComment();
  },
  listComment(page) {
    api.listComment(this.data.videoInfo.coursePO.id).then((res) => {
      this.setData({
        commentSet: res.data
      })
    })
  },

  onCommentSubmit() {
    let data = { "videoId": this.data.videoInfo.coursePO.id, commentContent: this.data.commentValue, wechatId: storage.getOpenId() }
    api.commentSubmit(data).then((res) => {
      this.listComment();
    })
    this.setData({
      commentValue: ""
    })
  },

  onReady: function () {

  },


  onShow: function () {

  },


  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})